import java.util.Scanner;

public class Test2 {
    // DNA 序列
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            int len = in.nextInt();
            int left = 0;
            int right = 0;
            char[] c = str.toCharArray();
            int cCount = 0;
            int gCount = 0;
            int maxCount = 0;
            int leftIndex = -1;
            int rightIndex = -1;
            for (; right < c.length; right++) {
                if (c[right] == 'C') {
                    cCount++;
                } else if (c[right] == 'G') {
                    gCount++;
                }
                if (right-left+1 == len) {
                    if (cCount > 0 && gCount > 0) {
                        if (cCount+gCount > maxCount) {
                            maxCount = cCount + gCount;
                            leftIndex = left;
                            rightIndex = right;
                        }
                    }
                    if (c[left] == 'C') {
                        cCount--;
                    } else if (c[left] == 'G') {
                        gCount--;
                    }
                    left++;
                }
            }
            System.out.println(str.substring(leftIndex, rightIndex+1));
        }
    }
}
